<template>
	<div>
		<el-row :gutter="24">
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">单位:</p>
			</el-col>
			<el-col :span="3" style="margin-left: 5px;">
				<el-input placeholder="请选择单位" size="small" icon="search" v-model="companyLabel" :on-icon-click="handleIconClicks">
				</el-input>
			</el-col>
			<el-col :span="1" style="margin-right:10px;margin-left: -5px;">
				<p class="queryLabel">所在仓库:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="condition.warehouse" left size="small" placeholder="请选择仓库" clearable>
					<el-option v-for="item in warehouseCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">入库时间:</p>
			</el-col>
			<el-col :span="3">
				<el-date-picker size="small" style="width: 100%;" v-model="condition.enterWarehouseDateStart" format="yyyy-MM-dd" :editable=false type="date" placeholder="起始日期">
				</el-date-picker>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">至</p>
			</el-col>
			<el-col :span="3">
				<el-date-picker size="small" style="width: 100%;" v-model="condition.enterWarehouseDateStop" format="yyyy-MM-dd" :editable=false type="date" placeholder="结束日期">
				</el-date-picker>
			</el-col>
			<el-col :span="1" style="margin-right:0px;">
				<p class="queryLabel">库龄:</p>
			</el-col>
			<el-col :span="3" style="margin-right: 0px;">
				<el-select size="small" v-model="condition.enterWarehouseAge" placeholder="请选择入库库龄" clearable>
					<el-option v-for="item in enterWarehouseAge" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
		</el-row>
		<el-row :gutter="24">
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">入库类型:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="condition.enterType" left size="small" placeholder="请选择入库类型" clearable>
					<el-option v-for="item in enterType" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">财务状态:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="condition.financeType" left size="small" placeholder="请选择财务状态" clearable>
					<el-option v-for="item in MStatusList" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-right: 10px;">
				<p class="queryLabel">车系:</p>
			</el-col>
			<el-col :span="3">
				<el-input placeholder="请选择车系" size="small" icon="search" v-model="carModelCode" :on-icon-click="handleIconClick">
				</el-input>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">车辆型号:</p>
			</el-col>
			<el-col :span="3">
				<el-select size="small" style="width: 100%;" v-model="condition.carModelCode" placeholder="请选择车型" clearable @change="changeModel">
					<el-option v-for="item in modelCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="">
				<p class="queryLabel">车辆配置:</p>
			</el-col>
			<el-col :span="3">
				<el-select size="small" style="width: 100%;" v-model="condition.carConfigureCode" placeholder="请选择配置" clearable>
					<el-option v-for="item in configCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
		</el-row>
		<el-row :gutter="24">
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">外观颜色:</p>
			</el-col>
			<el-col :span="3">
				<el-select size="small" style="width: 100%;" v-model="condition.appearanceId" placeholder="请选择外观" clearable>
					<el-option v-for="item in appearanceCombo" :label="item.label" :value="item.label"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">内饰:</p>
			</el-col>
			<el-col :span="3">
				<el-select size="small" style="width: 100%;" v-model="condition.interiorId" placeholder="请选择内饰" clearable>
					<el-option v-for="item in interiorCombo" :label="item.label" :value="item.label"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">加装名称:</p>
			</el-col>
			<el-col :span="3" style="float: left;">
				<el-input size="small" v-model="condition.installName" placeholder="输入加装名称" style="width:120!important"></el-input>
			</el-col>
			<el-col :span="1" style="margin-right:10px;">
				<p class="queryLabel">车辆状态:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="condition.saleType" left size="small" placeholder="请选择车辆状态" clearable>
					<el-option v-for="item in saleType" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-right:5px;">
				<p class="queryLabel">VIN:</p>
			</el-col>
			<el-col :span="3">
				<el-input placeholder="请输入VIN" size="small" v-model="condition.vin">
				</el-input>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="7" style="padding-left: 0px;text-align: right">
				<el-button type="primary" size="small" v-on:click='repertoryQuery'>查询</el-button>
				<el-button type="primary" size="small" @click="clean">清空查询条件</el-button>
				<el-button type="primary" size="small" v-on:click='editSale'>编辑销售状态</el-button>
				<el-button type="primary" size="small" v-on:click='download'>导出</el-button>
				<!--<el-button type="primary" size="small" v-on:click='applyFrozen'>申请冻结</el-button>
				<el-button type="primary" size="small" v-on:click='applyThaw'>申请解冻</el-button>
				<el-button type="primary" size="small" v-on:click='frozen'>同意冻结</el-button>
				<el-button type="primary" size="small" v-on:click='noFrozen'>拒绝冻结</el-button>
				<el-button type="primary" size="small" v-on:click='thaw'>同意解冻</el-button>
				<el-button type="primary" size="small" v-on:click='noThaw'>拒绝解冻</el-button>-->
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="24">
				<el-table :data="tableData.dataList" border style="width: 100%;align-content: center;" @selection-change="handleSelectionChange">
					<el-table-column type="selection" width="60">
					</el-table-column>
					<el-table-column label="VIN" prop="vin" width="170">
					</el-table-column>
					<el-table-column label="所在仓库" width="100" align="center" prop="warehouseName">
					</el-table-column>
					<el-table-column label="入库时间" width="120" align="center" prop="enterDate">
					</el-table-column>
					<el-table-column label="库存天数" width="100" align="center" prop="stockDay">
					</el-table-column>
					<el-table-column label="入库类型" width="100" align="center" prop="enterType" :formatter="enterTypeCov">
					</el-table-column>
					<el-table-column label="财务状态" width="120" align="center" prop="financeType" :formatter="MStatusCow">
					</el-table-column>
					<el-table-column label="车辆状态" width="100" align="center" prop="saleType" :formatter="carStatusCov">
					</el-table-column>
					<el-table-column label="发动机号" width="100" align="center" prop="engineNum">
					</el-table-column>
					<el-table-column label="车系名称" width="100" align="center" prop="carSeries">
					</el-table-column>
					<el-table-column label="车型名称" width="150" align="center" prop="carModel">
					</el-table-column>
					<el-table-column label="配置名称" width="170" align="center" prop="configure">
					</el-table-column>
					<el-table-column label="车型年(年款)" width="120" align="center" prop="carModelYear">
					</el-table-column>
					<el-table-column label="外观颜色" width="100" align="center" prop="appearanceName">
					</el-table-column>
					<el-table-column label="内饰名称" width="100" align="center" prop="trimName">
					</el-table-column>
					<el-table-column label="加装名称" width="100" align="center" prop="chooseName">
					</el-table-column>
					
					<el-table-column label="车辆状态描述" width="120" align="center" prop="saleTypeReason">
					</el-table-column>
					<el-table-column label="购货单位" width="120" align="center" prop="provideCompanyName">
					</el-table-column>
					<el-table-column label="总库存天数" width="100" align="center" prop="allStockDay">
					</el-table-column>

				</el-table>
				<el-pagination small @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="CurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="tableData.total">
				</el-pagination>
			</el-col>
		</el-row>
		<!--选择车系-->
		<carserice :show="showStart" v-if="showStart" v-on:close="showStart=false" v-on:insert="insert"></carserice>
		<!--修改车辆销售状态，可售、不可售，并填写原因-->
		<el-dialog title="修改原因" v-model="saleShow" size="small">
			<el-form :model="saleFormData" ref="saleForm" :rules="ruleSale" label-width="150px">

				<el-col :span="24">
					<el-form-item label="销售状态：" prop="saleType" required>
						<el-select v-model="saleFormData.saleType" left size="small" placeholder="请选择状态">
							<el-option v-for="item in saleType" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="调拨状态：" prop="allocationStatus" required>
						<!--allocationStatus-->
						<!--<template>
							<el-radio class="radio" v-model="allocationStatus" label="1">调拨锁定</el-radio>
							<el-radio class="radio" v-model="allocationStatus" label="0">调拨解锁</el-radio>
						</template>-->
						<el-checkbox v-model="checked" @change="checkdeChangeWithF">
							<aa id="aa" style="color: #969896 ;">{{$data.checkedstatus}}</aa>
						</el-checkbox>

					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="原因：" prop="saleTypeReason" required>
						<el-input size="small" v-model="saleFormData.saleTypeReason"></el-input>
					</el-form-item>
				</el-col>

			</el-form>

			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="saleShow = false">关 闭</el-button>
				<el-button type="primary" @click="saveSale">提 交</el-button>
			</div>
		</el-dialog>

		<company :show="showCompany" v-if="showCompany" v-on:close="showCompany=false" v-on:insert="inserts"></company>
	</div>
</template>
<script>
	import company from '../../insPlugins/company.vue'
	import carserice from '../../insPlugins/carSeries.vue'
	import moment from 'moment'
	export default {
		data: function() {
			return {
				pChecked: "true",
				// 是否锁定 
				checked: false,
				//锁定状态
				checkedstatus: "未选中",
				warehouseCombo: [],
				companyId: [],
				companyLabel: "",
				showCompany: false,
				//车辆销售状态修改开始===================================
				saleShow: false,

				saleType: [],
				allocationStatus: "0",
				allocationStatusList: [{
						label: "可调拨",
						value: "0",
					},
					{
						label: "调拨中",
						value: "1",
					},
					{
						label: "调拨锁定",
						value: "2",
					},
				],
				// 财务状态
				MStatusList: [{
						label: "财务未入库",
						value: "1",
					},
					{
						label: "暂估入库",
						value: "2",
					},
					{
						label: "正式入库",
						value: "3",
					},
				],

				saleFormData: {
					saleType: '',
					saleTypeReason: '',
					allocationStatus: '',
				},
				saleFormEmptyData: {
					saleType: '',
					saleTypeReason: '',
					allocationStatus: '',
				},

				ruleSale: {
					saleTypeReason: [{
						required: true,
						message: '请输入更改原因',
						trigger: 'blur'
					}],

				},

				//车辆销售状态修改结束===================================

				//弹窗选择单位==========================================
				//所有的组织机构树
				allTreeNode: [],

				//树型数据
				deptTreeData: [],
				//部门树
				defaultProps: {
					children: 'child',
					label: 'oName'
				},
				//默认选择中
				checkedResKeys: [],
				//显示单位
				deptShow: false,
				//弹窗选择单位==========================================

				//仓库下拉
				warehouse: [],
				//入库类型下拉
				enterType: [],
				//库龄下拉
				enterWarehouseAge: [],
				//页码数
				CurentPage: 1,
				//每页的数量
				page: this.page,
				//公司数据
				tableData: {
					total: 0,
					dataList: []
				},

				condition: {
					warehouse: '',
					enterType: '',
					enterWarehouseDateStart: '',
					enterWarehouseDateStop: '',
					appearanceId: '',
					interiorId: '',
					saleType: '',
					companyId: [],
					enterWarehouseAge: '',
					carModelCode: '',
					carConfigureCode: '',
					financeType: '',
					vin: "",
				},
				conditions: {
					warehouse: '',
					enterType: '',
					enterWarehouseDateStart: '',
					enterWarehouseDateStop: '',
					appearanceId: '',
					interiorId: '',
					saleType: '',
					companyId: [],
					enterWarehouseAge: '',
					carModelCode: '',
					carConfigureCode: '',
					financeType: '',
					vin: "",
				},

				repertoryFormShow: false,
				//校验规则
				Rule: {

				},
				repertoryFormData: {

				},
				emptyRepertoryFormData: {

				},

				applyFrozenFormData: {
					frozenReason: '',
				},

				applyFrozenEmptyFormData: {
					frozenReason: '',
				},

				applyThawFormData: {

				},

				applyThawEmptyFormData: {

				},
				multipleSelection: [],

				//车系车型配置联动==================
				showStart: false,
				//车型名称
				carModelCode: "",
				//配置的下拉
				configCombo: [],
				//车型的下拉
				modelCombo: [],
				//外观下拉
				appearanceCombo: [],
				//内饰下拉
				interiorCombo: [],
				//车系车型配置联动==================

			}
		},
		methods: {
			//库存导出
			download: function() {
				this.$data.condition.enterWarehouseDateStart = this.momentFu(this.$data.condition.enterWarehouseDateStart); //起始时间格式化
				this.$data.condition.enterWarehouseDateStop = this.momentFu(this.$data.condition.enterWarehouseDateStop); // 结束时间格式化
				this.$http.post(this.API_ROOT + '/scm/repertory/exports', this.$data.condition, {
						params: {}
					})
					.then(resp => {
						if(resp.data.success) {
							window.location.href = this.API_ROOT + "/base/exp/xlsx?fileId=" + resp.data.data + "&&fileName=库存明细-" + this.moment().format("YYYYMMDDHHmmss") + "&&fileType=xlsx";
						}
					}, resp => {});

				//window.location.href = this.API_ROOT + '/scm/monthlyBalance/exportDifferCost?uid=' + window.localStorage.getItem("uid") + "&date=" + this.$data.Date;
			},
			//单选框与说明文字绑定函数
			checkdeChangeWithF: function(row) {

				if(this.$data.checked == false) { // 选中
					this.$data.checkedstatus = "车辆可调拨";
					this.$data.saleFormData.allocationStatus = '0';

				} else { // 未选中
					this.$data.checked = true;
					this.$data.checkedstatus = "车辆已锁定";
					this.$data.saleFormData.allocationStatus = '1';
				}
			},

			//打开车型车系选择
			handleIconClicks: function() {
				this.$data.showCompany = true;
			},
			//给仓库增加全部的选项
			addWarehouse: function() {
				var warehouseEatem = {}; //{"label":"托管","id":"402881a25be71368015be74a12aa0009","value":"0"}
				warehouseEatem.label = "全部";
				warehouseEatem.value = "";
				this.$data.warehouseCombo.push(warehouseEatem);
			},
			//单位选择的回调
			inserts: function(val, lable) {
				debugger;
				this.$data.condition.companyId = val;
				this.$data.companyLabel = lable;
				//仓库
				this.$http.post(this.API_ROOT + '/scm/warehouse/comboIn', this.$data.condition.companyId, {
					params: {}
				}).then((response) => {
					debugger;
					this.$data.warehouseCombo = response.data;
					this.addWarehouse();
					//this.$message(response.data);
				}, (response) => {});
			},
			//财务状态转换
			MStatusCow: function(temp) {

				var h = "";

				switch(temp.financeType) {

					case '2':
						h = "暂估入库";
						break;

					case '3':
						h = "正式入库";
						break;

					default:
						h = "";
						break
				};
				return h;
			},

			/*MStatusList:[
			
				{
					label:"暂估入库",
					value:"2",
				},
				{
					label:"正式入库",
					value:"3",
				},
				],
				*/

			//弹窗选择车型 开始=====================================================================
			//车型改变的回调
			changeModel: function(val) {
				if(val != "") {
					this.comboConfigure(val);
				}
				debugger;
			},
			//车系选择的回调
			insert: function(val, lable) {
				debugger;
				this.$data.condition.carSeriesCode = val;
				this.$data.carModelCode = lable;
				//车型
				this.$http.get(this.API_ROOT + '/base/carModel/combo', {
					params: {
						seriesId: val
					}
				}).then((response) => {
					debugger;
					this.$data.modelCombo = response.data;
					this.$data.condition.carModelCode = "";
					this.$data.condition.carConfigureCode = "";
					//this.$message(response.data);
				}, (response) => {});

				//内饰
				debugger;
				this.$http.get(this.API_ROOT + '/scm/interior/combo', {

					params: {
						carSeriesId: val
					}
				}).then((response) => {
					debugger;
					this.$data.interiorCombo = response.data;
					this.$data.condition.interiorId = "";
					//this.$data.condition.carConfigureCode = "";
					//this.$message(response.data);
				}, (response) => {});

				//外观
				debugger;
				this.$http.get(this.API_ROOT + '/scm/appearance/combo', {
					params: {
						carSeriesId: val
					}
				}).then((response) => {
					debugger;
					this.$data.appearanceCombo = response.data;
					this.$data.condition.appearanceId = "";
					//this.$data.condition.carConfigureCode = "";
					//this.$message(response.data);
				}, (response) => {});

			},
			//选择车型后的回调
			comboConfigure: function(val) {
				this.$http.get(this.API_ROOT + '/base/carConfigure/combo', {
					params: {
						modelId: val
					}
				}).then((response) => {
					debugger;
					this.$data.configCombo = response.data;
					this.$data.condition.carConfigureCode = "";
					//this.$message(response.data);
				}, (response) => {});
			},
			//打开车型车系选择
			handleIconClick: function() {
				this.$data.showStart = true;
			},
			//弹窗选择车型 结束===================================================================
			//获取组织机构树的所有节点
			getTreeNode: function(treeAll) {
				debugger;
				for(var i = 0; i < treeAll.length; i++) {
					this.$data.allTreeNode.push(treeAll[i].id);
					if(treeAll[i].child.lenth == 0) {
						return;
					} else {
						this.getTreeNode(treeAll[i].child);
					}
				}
			},

			//选择框
			handleSelectionChange: function(val) {
				debugger;
				this.$data.multipleSelection = val;
			},

			applyFrozen: function() {
				this.$data.applyFrozenFormData = Object.assign(this.$data.applyFrozenFormData, this.$data.applyFrozenEmptyFormData);
				this.$data.repertoryFormShow = true;

			},

			//查询库存
			repertoryQuery: function() {
				this.$data.condition.enterWarehouseDateStart = this.momentFu(this.$data.condition.enterWarehouseDateStart); //起始时间格式化
				this.$data.condition.enterWarehouseDateStop = this.momentFu(this.$data.condition.enterWarehouseDateStop); // 结束时间格式化
				debugger;
				this.$http.post(this.API_ROOT + '/scm/repertory/page', this.$data.condition, {
					params: {
						start: this.$data.CurentPage,
						limit: this.$data.page.pageSize

					}
				}).then(resp => {
					if(resp.data.success) {
						resp.data.total = parseInt(resp.data.total);
						// es5写法
						this.$data.tableData = resp.data; //allocationStatus

						//this.$data.tableData.allocationStatus = this.statusCov(this.$data.tableData.allocationStatus);

						//this.baseQuery(this.$data.curTreeDeptId);
						//this.$data.exFormShow = false;
						debugger;
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//时间判断为空的封装
			momentFu: function(dt) {
				if(dt == '' || dt == null || dt == undefined) {
					return "";
				} else {
					return this.moment(dt).format("YYYY-MM-DD");
				}
			},
			//状态转换
			/*statusCov: function(temp) {
				
				switch(temp) {
					
					case '1':
						temp = true;
						break;
					
					default:
						temp = false;
						break
				};
				return temp;
			},*/
			//清空查询条件
			clean: function() {
				this.$data.condition.enterWarehouseDateStart = "";
				this.$data.condition.enterWarehouseDateStop = "";
				this.$data.condition = Object.assign(this.$data.condition, this.$data.conditions);
				this.$data.companyLabel = "";
				this.$data.carModelCode = "";
				this.$data.carSelectCompany = "";
			},
			//申请冻结
			applyFrozen: function() {
				if(this.$data.multipleSelection.length == 1) {
					debugger;
					var resRoleData = this.$data.multipleSelection[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/scm/repertory/applyFrozen',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						debugger;
						this.repertoryQuery();
					}, function(error) {})
				} else {
					this.$message.error("请选择一条数据");
				}
			},

			//管理员同意冻结
			frozen: function() {
				if(this.$data.multipleSelection.length == 1) {
					debugger;
					var resRoleData = this.$data.multipleSelection[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/scm/repertory/frozen',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						debugger;
						this.repertoryQuery();
					}, function(error) {})
				} else {
					this.$message.error("请选择一条数据");
				}
			},

			//管理员拒绝冻结
			noFrozen: function() {
				if(this.$data.multipleSelection.length == 1) {
					debugger;
					var resRoleData = this.$data.multipleSelection[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/scm/repertory/noFrozen',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						debugger;
						this.repertoryQuery();
					}, function(error) {})
				} else {
					this.$message.error("请选择一条数据");
				}
			},

			//申请解冻
			applyThaw: function() {
				if(this.$data.multipleSelection.length == 1) {
					debugger;
					var resRoleData = this.$data.multipleSelection[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/scm/repertory/applyThaw',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						debugger;
						this.repertoryQuery();
					}, function(error) {})
				} else {
					this.$message.error("请选择一条数据");
				}
			},

			//管理员同意解冻
			thaw: function() {
				if(this.$data.multipleSelection.length == 1) {
					debugger;
					var resRoleData = this.$data.multipleSelection[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/scm/repertory/thaw',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						debugger;
						this.repertoryQuery();
					}, function(error) {})
				} else {
					this.$message.error("请选择一条数据");
				}
			},

			//管理员拒绝解冻
			noThaw: function() {
				if(this.$data.multipleSelection.length == 1) {
					debugger;
					var resRoleData = this.$data.multipleSelection[0];
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/scm/repertory/noThaw',
						params: {
							id: resRoleData.id,
						}
					}).then(function(resp) {
						debugger;
						this.repertoryQuery();
					}, function(error) {})
				} else {
					this.$message.error("请选择一条数据");
				}
			},

			//入库类型解析
			enterTypeCov: function(row, column) {
				return this.$data.enterTypeConvertData[row.enterType];
			},
			enterTypeCovert: function() {
				this.$http.get(this.API_ROOT + '/base/dict/convert', {
					params: {
						group: "scmEnterWarehouseType"
					}
				}).then((response) => {
					this.$data.enterTypeConvertData = response.data;
					debugger;
				}, (response) => {});
			},
			/****************************************************************************8*/
			//车辆状态解析
			carStatusCov: function(row, column) {
				return this.$data.carStatusCovertData[row.saleType];
			},
			carStatusCovert: function() {
				this.$http.get(this.API_ROOT + '/base/dict/convert', {
					params: {
						group: "scmCarSaleStatus"
					}
				}).then((response) => {
					this.$data.carStatusCovertData = response.data;
				}, (response) => {});
			},

			//			//利用编辑接口填写冻结原因或者锁定原因
			//			reason: function() {
			//				debugger;
			//				if(this.$data.multipleSelection.length == 1) {
			//					var resRoleData = this.$data.multipleSelection[0];
			//					this.$http.get(this.API_ROOT + '/scm/warehouse/info', {
			//						params: {
			//							id: resRoleData.id
			//						}
			//					}).then((response) => {
			//						debugger;
			//						this.$data.warehouseFormData = Object.assign(this.$data.warehouseFormData, response.data.data);
			//					}, (response) => {
			//						// error callback
			//					});
			//					this.$data.warehouseFormShow = true;
			//				} else {
			//					this.$message.error("请选择一条数据");
			//				}
			//			},

			//车辆销售状态修改编辑=====================================================
			editSale: function() {
				this.$data.allocationStatus = "0"; // 单选框置零
				this.$data.saleFormData = Object.assign(this.$data.saleFormData, this.$data.saleFormEmptyData);
				this.checkdeChangeWithF(); // 刷新选框后提示
				this.$data.saleShow = true;

			},

			//修改车辆销售状态
			saveSale: function() {

				debugger;
				var resRoleData = this.$data.multipleSelection.slice();
				var id = [];
				for(var i = 0; i < resRoleData.length; i++) {
					id[i] = resRoleData[i].carId;
				}
				//					this.$http({
				//						method: 'POST',
				//						url: this.API_ROOT + '/scm/repertory/update',id,
				//						params: {
				//							//id: resRoleData.carId,
				//							saleType: this.$data.saleFormData.saleType,
				//							saleTypeReason: this.$data.saleFormData.saleTypeReason,
				//							allocationStatus: this.$data.saleFormData.allocationStatus,
				//						}
				//					})
				this.$http.post(this.API_ROOT + '/scm/repertory/update', id, {
					params: {
						saleType: this.$data.saleFormData.saleType,
						saleTypeReason: this.$data.saleFormData.saleTypeReason,
						allocationStatus: this.$data.saleFormData.allocationStatus,
					}
				}).then(function(resp) {
					debugger;
					this.$data.saleShow = false;
					this.repertoryQuery();
				}, function(error) {})

				this.$http.post(this.API_ROOT + '/scm/invoice/updateDetail', this.$data.comFormDataPrice.id, {
					params: {
						iid: this.$data.infoId,
						price: this.$data.comFormDataPrice.price
					}
				}).then((resp) => {
					if(resp.data.success) {
						this.$message("保存成功");
						this.$data.condition.invoiceTempTotal = resp.data.invoiceTotal;
						this.invoiceCarQuery();
					} else {
						////debugger;
						this.$message.error(resp.data.msg);
					}
				}, (response) => {});

			},

			//			//保存销售状态
			//			saveSale: function() {
			//				this.$refs.saleForm.validate(function(valid, $event) {
			//					// 验证通过
			//					if(valid) {
			//						debugger;
			//						this.$http.post(this.API_ROOT + '/scm/repertory/update')
			//							.then(resp => {
			//								if(resp.data.success) {
			//									debugger;
			//									this.repertoryQuery();
			//									this.$data.saleShow = false;
			//									this.$message(resp.data.msg);
			//								} else {
			//									this.$message.error(resp.data.msg);
			//								}
			//							}, resp => {
			//
			//							});
			//					} else {
			//						return false
			//					}
			//				}.bind(this))
			//			},
			//			
			//车辆销售状态修改编辑=====================================================

			//列表，分页大小切换
			handleSizeChange: function() {},
			//列表,当前页切换
			handleCurrentChange: function(currentPage) {
				this.$data.CurentPage = currentPage;
				//this.$data.dictGroup = '';
				this.repertoryQuery();
			},

		},

		components: {
			carserice,
			company
		},

		//表单创建时执行
		created: function() {
			var val = [];
			val[0] = window.localStorage.getItem("companyId");
			this.$data.companyLabel = window.localStorage.getItem("companyName");
			this.inserts(val, window.localStorage.getItem("companyName"));
			this.enterTypeCovert();
			this.carStatusCovert();
			this.repertoryQuery();
			//this.queryParamTree();

			//获取车辆入库库龄下拉
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "enterWarehouseAge"
				}
			}).then((response) => {
				this.$data.enterWarehouseAge = response.data;
			}, (response) => {});

			//弹窗选择单位============================================================

			//获取部门资源树
			this.$http.get(this.API_ROOT + '/rbac/dept/tree', {
				params: {
					root: window.localStorage.getItem("companyId"),
					type: "1",
				}
			}).then((response) => {
				this.$data.deptTreeData = response.data.dataList;
				this.$data.allTreeNode = [];
				this.getTreeNode(this.$data.deptTreeData);
			}, (response) => {});

			//弹窗选择单位==========================================================

			//获取车辆入库类型下拉
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "scmEnterWarehouseType"
				}
			}).then((response) => {
				this.$data.enterType = response.data;
			}, (response) => {});

			//获取车辆销售状态下拉
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "scmCarSaleStatus"
				}
			}).then((response) => {
				this.$data.saleType = response.data;
			}, (response) => {});

			//仓库下拉
			this.$http.get(this.API_ROOT + '/scm/warehouse/combo', {
				params: {}
			}).then((response) => {
				this.$data.warehouse = response.data;
			}, (response) => {});

			//获取仓库类型下拉
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "warehouse"
				}
			}).then((response) => {
				this.$data.warehouseType = response.data;
			}, (response) => {});

		}
	}
</script>
<style>
	.el-table .info-row {
		height: 10px !important;
	}
	
	.item {
		width: 30px;
	}
	
	.el-form-item {
		clear: both;
	}
	
	.el-dropdown .el-button-group,
	.el-table .el-tooltip,
	.el-table .el-tooltip__rel {
		display: inline;
	}
	
	.el-table {
		height: 100%;
		width: 100%;
	}
	
	#el-select {
		width: 200px;
	}
</style>